﻿using ComicWeb.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace ComicWeb.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class VComicsInfoGxController : ControllerBase
    {
        private readonly ShopContext _context;
        //注入依赖
        public VComicsInfoGxController(ShopContext context)
        {
            _context = context;
        }
        // GET: api/VClassifications
        /// <summary>
        ///搞笑漫画显示
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<ActionResult<IEnumerable<VComicsInfoGx>>> ComicsinfoGX()
        {
            List<VComicsInfoGx> li = new List<VComicsInfoGx>();
            var data = _context.VComicsInfoGxes;
            foreach (var item in data)
            {
                if (item.ComicCtentent == "完结")
                {
                    item.ComicCtentent = $"[完结] 共{item.Hs}话";
                    li.Add(item);
                }
                else
                {
                    item.ComicCtentent = $"更新至{item.Hs}话";
                    li.Add(item);
                }
            }
            return li;
        }
    }
}
